#ifndef BLOCKINGQUEUE_H
#define BLOCKINGQUEUE_H

#include "queue.h"
#include <sys/types.h>
struct blockingqueue;
typedef struct blockingqueue blockingqueue_t;
typedef blockingqueue_t* blockingqueue;

struct blockingqueue{
    queue q;
    pthread_mutex_t mutex;
    pthread_cond_t cond;

    int (*is_empty)(blockingqueue this);
    //non-blocking
    int (*push)(blockingqueue this,void* data);
    //blocking 
    void* (*pop)(blockingqueue this,u_int64_t timeout);
    //blocking
    void* (*top)(blockingqueue this,u_int64_t timeout);
    //non-blocking 
    void* (*try_pop)(blockingqueue this);
    //non-blocking
    void* (*try_top)(blockingqueue this);
    //non-blocking
    void (*clear)(blockingqueue this);
    //non-blocking
    void (*destory)(blockingqueue this);
};

extern blockingqueue create_blockingqueue();

#endif